package com.lieve.tx.typeinfo;

import java.util.Random;

import static com.lieve.tx.util.Print.print;

/**
 * @author sunyoboy
 * 2020/9/26
 */
class Initable {
    static final int staticFinal = 47;
    static final int staticFinal2 = ClassInitialization.random.nextInt(1000);
    static {
        print("Initializing Initable");
    }
}

class Initable2 {
    static int staticNonFinal = 147;
    static {
        print("Initializing Initable2");
    }
}

class Initable3 {
    static int staticNonFinal = 74;
    static {
        print("Initializing Initable3");
    }
}

public class ClassInitialization {
    public static Random random = new Random(47);

    public static void main(String[] args) {
        Class initable = Initable.class;
        print("after creating Initable ref");
        System.out.println(Initable.staticFinal);
        System.out.println(Initable.staticFinal2);
        System.out.println(Initable2.staticNonFinal);
        try {
            Class initabl3 = Class.forName("com.lieve.tx.typeinfo.Initable3");
        } catch (ClassNotFoundException e) {
            print("cannot find Initable3");
        }
        print("after creating Initable3 ref");
        print(Initable3.staticNonFinal);
    }
}
